@extends('admin.layout.index')

@section('content')

<div class="portlet-body form">

	<!-- BEGIN FORM-->
{{--
	<form action="/admin/goods" method = "get" id="form_sample_1" class="form-horizontal">
		<div class="control-group">
    
			<label class="control-label">选择商品分类<span class="required">*</span></label>
			<div class="controls">
				<select class="span6 m-wrap" name="pid" >
					<option value="">---请选择---</option>
					@foreach($type as $m=>$n)
            <option value="{{$n['pid']}}">{{$n['name']}}</option>
          @endforeach
				</select>
			</div>
		</div>
	</form>
--}}
	<div class="portlet box light-grey">
  <div class="portlet-title">
    <div class="caption">
      <i class="icon-globe"></i>商品列表</div>
    <div class="tools">
      <a href="javascript:;" class="collapse"></a>
      <a href="#portlet-config" data-toggle="modal" class="config"></a>
      <a href="javascript:;" class="reload"></a>
      <a href="javascript:;" class="remove"></a>
    </div>
  </div>
  <div class="portlet-body">
    <div class="clearfix"></div>
    <div id="sample_1_wrapper" class="dataTables_wrapper form-inline" role="grid">
      <div class="row-fluid">
        <form method="get" action="/admin/goods">
          <div class="span6">
            <div class="dataTables_filter" id="DataTables_Table_1_filter">
              <label>关键字: <input type="text" name="search" value="{{$request['search'] or ''}}" aria-controls="DataTables_Table_1">
              <input type="submit" class="btn btn-success btn-xs" value="搜索"></label>
            </div>
          </div>
        </form>
      </div>
      <table class="table table-striped table-bordered table-hover dataTable" id="sample_1" aria-describedby="sample_1_info">
        <thead>
          <tr role="row" >
            <th style="width: 24px;" class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="">
              <div class="checker">
                <span>
                  <input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes"></span>
              </div>
            </th>
            
            <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="Joined" >ID</th>
            <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="Joined" >卖家名</th>
            <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="Joined" >商品分类</th>
            <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="Joined" >商品标题</th>
            <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="Joined" >商品描述</th>
            <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="Joined" >价格</th>
            <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="Joined" >数量</th>
            <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="Joined" >成色</th>
            <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="Joined" >发布时间</th>
            <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="Joined" >操作</th>
            
          </tr>
        </thead>
        <tbody role="alert" aria-live="polite" aria-relevant="all">
          @foreach($data as $k=>$v)
          <tr class="gradeX odd">
            <td class="  sorting_1">
              <div class="checker">
                <span>
                  <input type="checkbox" class="checkboxes" value="1"></span>
              </div>
            </td>
            
            <td >{{$v['id']}}</td>
            <td >{{$v['uid']}}</td>
            <td >{{$v['tid']}}</td>
            <td >{{$v['title']}}</td>
            <td >{{$v['intro']}}</td>
            <td >{{$v['reprice']}}</td>
            <td >{{$v['num']}}</td>
            <td >{{$v['condition']}}</td>
            <td >{{$v['ctime']}}</td>
            
            <td >
              <a href="">查看商品</a>
            	<a href="javascript:void(0)" onclick="delGoods({{$v['id']}})">删除</a>
            	<a href="{{url('admin/goods/changeStatus/'.$v['id'])}}">{{$v['status']==0?"下架":"上架"}}</a>
            </td>
            
          </tr>
          @endforeach
        </tbody>
      </table>
      <div  class="dataTables_paginate paging_bootstrap pagination" style="float:right;">
        {!! $data->appends($request)->render()!!}
      </div>
  </div>
</div>

	<!-- END FORM-->

</div>
<script>
    function delGoods(goodsid){

            layer.confirm('是否确认删除？', {
                btn: ['确认','取消'] //按钮
            }, function(){
                //            jQuery.post(url,data,success(data, textStatus, jqXHR),dataType)
                $.post('{{url('admin/goods/')}}/'+goodsid,{'_token':'{{csrf_token()}}','_method':'delete'},function(data){
                    //console.log(data);
//                    删除成功
                    if(data.status == 0){
                        layer.msg(data.msg, {icon: 6});
                        location.href = location.href;
                    }else{
                        layer.msg(data.msg, {icon: 5});
                        location.href = location.href;
                    }
                });

            }, function(){

            });
        }

</script>
@endsection